package com.ww.learn.oop.sam

/**
 * 支持空安全
 */

fun interface SafeProcessor {
    fun process(input: String?): String?
}

fun handleInput(input: String?, processor: SafeProcessor): String? {
    return processor.process(input)
}

fun main() {
    val result1 = handleInput("hello") { it?.uppercase() }
    val result2 = handleInput(null) { it?.uppercase() ?: "DEFAULT" }

    println(result1)
    println(result2)
}
